package Map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {
	public static void main(String[] args) {
		HashMap<String,String> hm = new HashMap<String,String>();
		hm.put("001", "张三");
		hm.put("002", "李四");
		hm.put("003", "王五");
		//方法1：通过获取所有的key，通过key来获取value
		Set<String> keys = hm.keySet();
		for(String key:keys) {
			String value = hm.get(key);
			System.out.println(value);
		}
		
		//方法2:获取所有的Entry对象，然后通过Entry对象获取key和value
		Set<Map.Entry<String, String>> entrys = hm.entrySet();
		for(Map.Entry<String, String> entry:entrys) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println(key + value);
			
		}
		
	}
}
